#include "GameState.h"
#include "LogicEngine.h"

class LogicEngine;
	StoryState* StoryState::Instance()
	{
		static StoryState instance;

		return &instance;
	}

	void StoryState::Enter(LogicEngine* lsm)
	{
	}


	void StoryState::Execute(LogicEngine* lsm)
	{  
		lsm->sendMessage("NextScene");
	}


	void StoryState::Exit(LogicEngine* lsm)
	{
	}

	bool StoryState::OnMessage(LogicEngine* lsm,boost::any p)
	{
		return true;
	}

	FightState::FightState()
		:m_fSM(0)
	{
	}

	FightState* FightState::Instance()
	{
		static FightState instance;

		return &instance;
	}

	void FightState::Enter(LogicEngine* lsm)
	{
		ObjectId fightSMId=lsm->createObject();
		lsm->addComponent(fightSMId,&m_fSM);
		lsm->sendLocalMessage("ChangeToFightState");
	}


	void FightState::Execute(LogicEngine* lsm)
	{
	}


	void FightState::Exit(LogicEngine* lsm)
	{
	}

	bool FightState::OnMessage(LogicEngine* lsm,boost::any p)
	{
		vector<boost::any>* any=boost::any_cast<vector<boost::any>*>(p);
		vector<boost::any>::iterator iter=any->begin();
		_SYSTEM_MESSAGE sm=boost::any_cast<_SYSTEM_MESSAGE>(*iter++);
		switch(sm)
		{
		case MOUSE_LEFT_CLICKED:
			m_fSM.GetFSM()->CurrentState()->OnMessage(&m_fSM,p);
			break;
		case MOUSE_RIGHT_CLICKED:
			m_fSM.GetFSM()->CurrentState()->OnMessage(&m_fSM,p);
			break;
		}
		return true;
	}

	MenuState* MenuState::Instance()
	{
		static MenuState instance;

		return &instance;
	}

	void MenuState::Enter(LogicEngine* lsm)
	{
	}


	void MenuState::Execute(LogicEngine* lsm)
	{
		lsm->GetFSM()->ChangeState(FightState::Instance());
	}


	void MenuState::Exit(LogicEngine* lsm)
	{
	}

	bool MenuState::OnMessage(LogicEngine* lsm,boost::any)
	{
		return true;
	}